package com.feizhi.common.search.index.action;

import org.springframework.beans.factory.annotation.Autowired;

import com.feizhi.common.search.index.LuceneWork;

/**
 * @author shuaqiu
 */
public class UpdateIndexAction extends AbstractIndexAction implements IndexAction {

    private DeleteIndexAction deleteIndexAction;

    private AddIndexAction addIndexAction;

    @Autowired
    public void setDeleteIndexAction(final DeleteIndexAction deleteIndexAction) {
        this.deleteIndexAction = deleteIndexAction;
    }

    @Autowired
    public void setAddIndexAction(final AddIndexAction addIndexAction) {
        this.addIndexAction = addIndexAction;
    }

    @Override
    public void performAction(final LuceneWork work) {
        // This is the slowest implementation, needing to remove and then add to the index;
        // see also com.feizhi.common.index.ExtUpdateIndexAction
        deleteIndexAction.performAction(work);
        addIndexAction.performAction(work);
    }

}
